import { ConfigEnv, defineConfig } from 'vite'
import {createSvgIconsPlugin} from 'vite-plugin-svg-icons';
import path from 'path';
import vue from '@vitejs/plugin-vue'
import {viteMockServe} from 'vite-plugin-mock'
// https://vite.dev/config/
export default defineConfig(({command}:ConfigEnv)=>{
  return {
    plugins: [vue(),
        createSvgIconsPlugin({
          // Specify the icon folder to be cached
          iconDirs: [path.resolve(process.cwd(), 'src/assets/icons')],
          // Specify symbolId format
          symbolId: 'icon-[dir]-[name]',
        }),
/*         viteMockServe({
       //enable: process.env.NODE_ENV === 'development' // 或者 command === 'serve'
       mockPath:'./src/mock',//指定路径，不然可能404
       enable: command === 'serve' ,
        }) */
    ],
    resolve:{
      alias:{
        "@": path.resolve("./src")
      },
    },
    css: {
      preprocessorOptions: {
        scss: {
          javascriptEnabled: true,
          additionalData: '@import "./src/styles/variable.scss";',
        },
      },
    },
    server: {

      host: '0.0.0.0'

  }
  
  }
}
)